#include <iostream>
#include <unordered_map>
using namespace std;

const int N = 1e6 + 10;
int T,n,x[N];

int main(){
	cin >> T;
	while(T--){
		cin >> n;
		for(int i = 1;i <= n;i++){
			cin >> x[i];
		}
		int le = 1,ri = 1,ret = 0;
		unordered_map<long long,int> mp;
		while(ri <= n){
			mp[x[ri]]++;
			while(mp[x[ri]] > 1){
				mp[x[le]]--;
				le++;
			}
			ret = max(ret,ri - le + 1);
			ri++;
		}
		cout << ret << endl;
	}
	return 0;
}
